#include "stdafx.h"
#include "structures.h"


bool sortVertices(const figureVertice & f1, const figureVertice & f2)
{
  if(f1.y > f2.y) 
    return true;
  else
  {
    if((f1.y == f2.y) && (f1.x < f2.x))
      return true;
    else
      return false;
  }
}
/*
bool operator < (const figureEdge & e1, const figureEdge & e2)
{
  //if((e1._begin.x < e2._begin.x) || (e1._end.x < e2._end.x))
  //if((e1._begin == e2._begin) && (e1._end == e2._end))
  //  return false;
  if(min(e1._begin.x,e1._end.x) < min(e2._begin.x,e2._end.x))
    return true;
  else
  {
    if((min(e1._begin.x,e1._end.x) == min(e2._begin.x,e2._end.x)) &&
       (max(e1._begin.x,e1._end.x) < max(e2._begin.x,e2._end.x)))
      return true;
    else
      return false;
  }
};
*/

bool operator < (const figureEdge & e1, const figureEdge & e2)
{
  //if((e1._begin.x < e2._begin.x) || (e1._end.x < e2._end.x))
  //if((e1._begin == e2._begin) && (e1._end == e2._end))
  //  return false;
  if(min(e1._begin.y,e1._end.y) < min(e2._begin.y,e2._end.y))
    return true;
  else
  {
    if((min(e1._begin.y,e1._end.y) == min(e2._begin.y,e2._end.y)) &&
       (max(e1._begin.y,e1._end.y) < max(e2._begin.y,e2._end.y)))
      return true;
    else
    {
      if((min(e1._begin.y,e1._end.y) == min(e2._begin.y,e2._end.y)) &&
         (max(e1._begin.y,e1._end.y) == max(e2._begin.y,e2._end.y)) &&
         (min(e1._begin.x,e1._end.x) < min(e2._begin.x,e2._end.x)))
         return true;
      else
      {
        if((min(e1._begin.y,e1._end.y) == min(e2._begin.y,e2._end.y)) &&
           (max(e1._begin.y,e1._end.y) == max(e2._begin.y,e2._end.y)) &&
           (min(e1._begin.x,e1._end.x) == min(e2._begin.x,e2._end.x)) &&
           (max(e1._begin.x,e1._end.x) <  max(e2._begin.x,e2._end.x)))
         return true;
      }
      return false;
    }
  }
}

bool operator > (const figureEdge & e1, const figureEdge & e2)
{
  return (!(e1 < e2));
}

bool operator == (const figureEdge & e1, const figureEdge & e2)
{
  return ((e1._begin == e2._begin) && (e1._end == e2._end));
}


bool operator > (const figureVertice & f1, const figureVertice & f2)
{
  return(sortVertices(f1,f2));
}

bool operator < (const figureVertice & f1, const figureVertice & f2)
{
  return(!(sortVertices(f1,f2)));
}


bool figureEdge::operator == (const figureEdge & fg)
{
  if((_begin == fg._begin) && (_end == fg._end) &&
     (_order == fg._order))
    return true;
  else
    return false;
}

/*
bool operator == (const figureEdge & e1, const figureEdge & e2)
{
  if((e1._begin == e2._begin) && (e1._end == e2._end) &&
   (e1._order == e2._order))
     return true;
  else
    return false;
}
*/
bool figureVertice::operator == (const figureVertice & fg)
{
  if((x == fg.x) && (y == fg.y))// && (_type == fg._type))
    return true;
  else
    return false;
}

bool figureVertice::operator > (const figureVertice & fg)
{
  /*if( *this > fg)// && (_type == fg._type))
    return true;
  else
    return false;*/
    return(sortVertices(*this,fg));
}

bool figureVertice::operator == (const POINT & p)
{
  if((x == p.x) && (y == p.y))
    return true;
  else
    return false;
}

figureVertice & figureVertice::operator = (const POINT & p)
{
  x = p.x;
  y = p.y;
  return(*this);
}


bool operator == (const figureVertice & v1, const figureVertice & v2)
{
  if((v1.x == v2.x) && (v1.y == v2.y))
    return true;
  else
    return false;
}

bool operator != (const figureVertice & v1, const figureVertice & v2)
{
  return (!(v1 == v2));
}